<%--
  Created by IntelliJ IDEA.
  User: benhailong
  Date: 2018/2/7
  Time: 下午3:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>OpenKit快速项目开发工具</title>
    <link rel="stylesheet" href="<%=basePath%>templates/style/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=basePath%>templates/style/build/css/doc.css" media="all">
    <script src="<%=basePath%>templates/style/plugins/layui/layui.js"></script>
    <script src="<%=basePath%>templates/style/plugins/layui/jquery-3.3.1.min.js"></script>
</head>
<body style="padding: 10px">
    <blockquote class="layui-elem-quote layui-text">
        OpenKit快速开发工具，基于原有的微擎模块，后台采用layui作为基础架构，一键生成
    </blockquote>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>微擎模块快速生成工具</legend>
    </fieldset>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">项目类型</label>
            <div class="layui-input-block">
                <input type="radio" name="project_type" value="1" title="微擎模块" checked="">
            </div>
        </div>
        <%--<div class="layui-form-item">--%>
            <%--<label class="layui-form-label">支持</label>--%>
            <%--<div class="layui-input-block">--%>
                <%--<input type="checkbox" name="support[]" value="wxapp" title="微信小程序" checked="">--%>
                <%--<input type="checkbox" name="support[]" value="wx" title="微信公众号" >--%>
            <%--</div>--%>
        <%--</div>--%>

        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-block">
                <input type="text" name="project_name" lay-verify="required" value="测试名称" placeholder="名称中不要包含版本号。名称审核通过后不可修改" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">标识</label>
            <div class="layui-input-block">
                <input type="text" name="sign" lay-verify="required" value="up_type" placeholder="输入模块标识(只能包括字母和数字，且只能以字母开头，格式如：aa1_bb1或aa_bb)" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">作者</label>
            <div class="layui-input-block">
                <input type="text" name="author" lay-verify="required" value="ben" placeholder="请输入项目作者" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">作者官网</label>
            <div class="layui-input-block">
                <input type="text" name="web" lay-verify="required" value="http://www.ananwulian.com" placeholder="作者的网址" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">模块描述</label>
            <div class="layui-input-block">
                <textarea placeholder="模块详细描述，模块安装后在微擎中显示，简要介绍模块的功能和使用方法"  name="describe" class="layui-textarea">模块描述</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">生成项目</button>
        </div>


    </form>

<div id="loading"></div>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['form'], function(){
            var form = layui.form,
            layer = layui.layer;

            //监听提交
            form.on('submit(add)', function(data){
                layer.load(4);
                $.ajax({
                    type: 'POST',
                    url: '<%=basePath%>peoject/index',
                    async: true,
                    data: data.field,
                    success:function(data){

                        if(data.code!=200){
                            layer.alert(data.msg, {offset: 't',icon: 5});
                        }
                        if(data.code==200){
                            window.location.href= data.msg;
                        }

                        layer.closeAll('loading');
                    },
                });
                return false;
            });
        });
    </script>
</body>
</html>